package com.ruoyi.web.controller.base;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.base.domain.BusWaterRainfallstation;
import com.ruoyi.base.service.IBusWaterRainfallstationService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 雨量站Controller
 * 
 * @author maliang
 * @date 2025-07-27
 */
@RestController
@RequestMapping("/base/rainfallstation")
public class BusWaterRainfallstationController extends BaseController
{
    @Autowired
    private IBusWaterRainfallstationService busWaterRainfallstationService;

    /**
     * 查询雨量站列表
     */
    //@PreAuthorize("@ss.hasPermi('base:rainfallstation:list')")
    @GetMapping("/list")
    public TableDataInfo list(BusWaterRainfallstation busWaterRainfallstation)
    {
        startPage();
        List<BusWaterRainfallstation> list = busWaterRainfallstationService.selectBusWaterRainfallstationList(busWaterRainfallstation);
        return getDataTable(list);
    }

    /**
     * 导出雨量站列表
     */
    //@PreAuthorize("@ss.hasPermi('base:rainfallstation:export')")
    @Log(title = "雨量站", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BusWaterRainfallstation busWaterRainfallstation)
    {
        List<BusWaterRainfallstation> list = busWaterRainfallstationService.selectBusWaterRainfallstationList(busWaterRainfallstation);
        ExcelUtil<BusWaterRainfallstation> util = new ExcelUtil<BusWaterRainfallstation>(BusWaterRainfallstation.class);
        util.exportExcel(response, list, "雨量站数据");
    }

    /**
     * 获取雨量站详细信息
     */
    //@PreAuthorize("@ss.hasPermi('base:rainfallstation:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(busWaterRainfallstationService.selectBusWaterRainfallstationById(id));
    }

    /**
     * 新增雨量站
     */
    //@PreAuthorize("@ss.hasPermi('base:rainfallstation:add')")
    @Log(title = "雨量站", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BusWaterRainfallstation busWaterRainfallstation)
    {
        return toAjax(busWaterRainfallstationService.insertBusWaterRainfallstation(busWaterRainfallstation));
    }

    /**
     * 修改雨量站
     */
    //@PreAuthorize("@ss.hasPermi('base:rainfallstation:edit')")
    @Log(title = "雨量站", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BusWaterRainfallstation busWaterRainfallstation)
    {
        return toAjax(busWaterRainfallstationService.updateBusWaterRainfallstation(busWaterRainfallstation));
    }

    /**
     * 删除雨量站
     */
    //@PreAuthorize("@ss.hasPermi('base:rainfallstation:remove')")
    @Log(title = "雨量站", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(busWaterRainfallstationService.deleteBusWaterRainfallstationByIds(ids));
    }
}
